package com;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class SnakePn extends JPanel {
	private static final long serialVersionUID = 1L;
	private Snake snake;

	public SnakePn(Snake snake) {
		super();
		this.snake = snake;
	}

	@Override
	public void paint(Graphics s) {
		super.paint(s);
		Color color = Color.RED;
		for (Node node : snake.body) {
			s.setColor(color);
			s.fill3DRect(node.getX(), node.getY(), Node.WIDTH, Node.HEIGHT, true);
			color = color.getRGB() == Color.RED.getRGB() ? Color.GRAY : Color.RED;
		}
		Node food = snake.getFood();
		s.setColor(Color.BLUE);
		s.fill3DRect(food.getX(), food.getY(), Node.WIDTH, Node.HEIGHT, true);
	}

}
